package cn.hn.tx.mail.service.impl;

import java.util.List;

import cn.hn.comm.ibatis.BaseDAO;
import cn.hn.tx.mail.model.MailAccount;
import cn.hn.tx.mail.model.MailAddress;
import cn.hn.tx.mail.model.MailContent;
import cn.hn.tx.mail.service.IMailService;

public class MailServiceImpl implements IMailService {

	final String NAMESPACE = "cn.hn.tx.mail.dao";

	// DAO基类
	private BaseDAO baseDAO;

	public Integer insertMailAddress(MailAddress ma) {
		return (Integer) baseDAO.insert(NAMESPACE, "insertMailAddress", ma);
	}

	public List<MailAddress> queryAllMailAddress() {
		return baseDAO.queryList(NAMESPACE, "queryAllMailAddress", null);
	}
	
	public List<MailAddress> queryAllMailAddressByStatus(Integer status)
	{
		return baseDAO.queryList(NAMESPACE, "queryAllMailAddressByStatus", status);
	}

	public List<MailAccount> queryAllMailAccountByStatus(Integer status)
	{
		return baseDAO.queryList(NAMESPACE, "queryAllMailAccountByStatus", status);
	}
	
	public MailAddress queryMailAddress(int id) {
		return (MailAddress) baseDAO.query(NAMESPACE, "queryMailAddress", id);
	}

	public void updateMailAddress(MailAddress ma) {
		baseDAO.update(NAMESPACE, "updateMailAddress", ma);

	}

	public List<MailAccount> queryAllMailAccount() {
		return baseDAO.queryList(NAMESPACE, "queryAllMailAccount", null);
	}

	public void updateMailContent(MailContent mc) {
		baseDAO.update(NAMESPACE, "updateMailContent", mc);

	}

	public MailContent queryOldestMailContent() {
		return (MailContent)baseDAO.query(NAMESPACE, "queryOldestMailContent", null);
	}
	
	public MailContent queryOldestMailContentByStatus(Integer status)
	{
		return (MailContent)baseDAO.query(NAMESPACE, "queryOldestMailContentByStatus", status);
	}

	public BaseDAO getBaseDAO() {
		return baseDAO;
	}

	public void setBaseDAO(BaseDAO baseDAO) {
		this.baseDAO = baseDAO;
	}
}
